home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / pcto48 < prev    next >
Internet Message Format  |  1995-03-31  |  7KB

  1. From jodell@hpcupt1.HP.COM Fri Jul 13 09:09:01 1990
  2. From: jodell@hpcupt1.HP.COM (Jamie Odell)
  3. Newsgroups: comp.sys.handhelds
  4. Subject: Power of 48 from your PC
  5. Date: 11 Jul 90 01:01:46 GMT
  6. Organization: Hewlett Packard, Cupertino
  7.  
  8. Several people have mentioned the lack of support for "Using the Power of Your
  9. HP-48sx from your PC" in the cable/software package.  In order to help bridge
  10. that gap - and mostly because I can't type long programs on the 48's keyboard
  11. - I have written a program that allows object entry from a terminal or
  12. terminal emulator.  This program works, but it is far from complete.  I wrote
  13. it basically to see if I could do it.  I hope that someone can get some good
  14. use out of it.
  15.  
  16.  
  17. Purpose: This program will allow a user to type objects on a terminal (or
  18. terminal emulator directly to the HP-48sx.
  19.  
  20. Directions for use: Download the directory TERM.  Setup your IOPAR variable
  21. for XON XOFF and for whatever other communication parameters you want to use.
  22. For example: for 9600 baud, no parity checking, and XON XOFF - your IOPAR
  23. variable could be { 9600 0 1 1 3 1 }.  Note that the translate code, and
  24. checksum type are not used.
  25.  
  26. Connect the 48sx to your terminal or PC and set up the communication
  27. parameters on both the 48 and PC. Make TERM the current directory, and execute
  28. TRM.  You should see:
  29.                 Term Entry 1.0
  30. on your terminal screen, as well as on the 48sx screen.
  31.  
  32. Now you can type things on your terminal.  Each character is sent to the 48.
  33. To tell the 48 that you are finished with the current object, type END on a
  34. line by itself.
  35.  
  36. All the lines you have typed so far will be combined into an object and left
  37. on the stack.
  38.  
  39. The backspace key (Control-H) will delete the last character you typed on a
  40. current line.  This is the only form of editing allowed.
  41.  
  42. To enter the symbols "<<", ">>", or "->" you should type \<<, \>>, \->
  43. respectively.  The program automatically takes care of converting the symbols.
  44.  
  45. Since this program uses XMIT and SRECV for I/O, the translate code in IOPAR is
  46. not used.  This means that \<<, \>>, and \-> will be the only symbols
  47. converted.
  48.  
  49. Please note that this is the 1.0 version of this program.  I wrote it quickly
  50. because I wanted to be able to use a typewriter keyboard to enter data into
  51. the 48.  I have some ideas for enhancements such as better editing
  52. capabilities, two way data transfer, more control of the 48 from a terminal,
  53. etc.  If I get the chance, I'll add some of these features.
  54.  
  55. Also, and this is VERY IMPORTANT.  This code expects the stack to be empty
  56. before it is run.  I know this is not good calculator programming etiquette,
  57. but hey, I'll fix it in a later release. As you've probably guessed, I'm a
  58. software engineer :-)
  59.  
  60. Feel free to do whatever you want to this code.  Please let me know if you
  61. make any cool enhancements.
  62.  
  63. The directory contains the following objects:
  64.  
  65. TRM - Main entry point to this program.  This saves the current flags, prints
  66. "Term Entry 1.0" on the 48's display, and calls GETPROG.  Flag 2 is set. Flag
  67. 2 does not mean anything.  It was supposed to mean that the program should
  68. echo characters back to the terminal.   The program always echos characters to
  69. the terminal, so flag 2 doesn't do anything.  I should remove it, but I
  70. haven't yet.
  71.  
  72. GETPROG - Get a program (or any object).  This procedure opens I/O
  73. communications, clears the I/O buffer, and sends "Term Entry 1.0" to the
  74. Terminal.  Then it collects lines of text, until the user types "END".
  75. Afterwards, it combines all the lines of text into a single object and leaves
  76. it on the stack.
  77.  
  78. READLN - Reads a line of text.  A line is a string of characters terminated
  79. with a carriage return.
  80.  
  81. FIXLN - Convert \<<, \>>, \-> into their 48sx representations everywhere they
  82. appear in a line.
  83.  
  84. CNVR - Convert all the strings on the stack (lines) into one object.
  85.  
  86. READCH - Read a single character from the terminal, and add it to the current
  87. string.  If the character is a backspace, then erase one character from the
  88. string.  If the character is a carriage return, then echo a carriage return,
  89. line feed sequence.
  90.  
  91. DECL - Remove one character from the current line.
  92.  
  93. LIN - Current line is stored here.  When the line is terminated, it gets
  94. pushed as a string onto the stack.
  95.  
  96. Jamie Odell
  97. MXO - Commercial Systems Division (CSY)
  98. Hewlett-Packard Co.
  99. jodell@hpda.hp.com
  100.  
  101. ------------------------------------------------------------------------------
  102. #FD90h 953
  103. %%HP: T(3)A(D)F(.);
  104. DIR
  105.   TRM
  106.     \<< CLLCD
  107. "Term Entry 1.0" 1
  108. DISP RCLF \-> f
  109.       \<< 2 SF             @ Set terminal echo on (not used!).
  110. GETPROG f STOF
  111.       \>>
  112.     \>>
  113.   GETPROG
  114.     \<< OPENIO BUFLEN
  115. DROP SRECV DROP            @ Clear the serial I/O buffer before doing anything
  116. DROP
  117. "Term Entry 1.0" 13
  118. CHR + 10 CHR + XMIT        @ Transmit message with CR/LF
  119. DROP
  120.       DO READLN LIN        @ Read in next line
  121. FIXLN                      @ Convert special characters to 48 characters
  122.       UNTIL LIN
  123. "END" 13 CHR + SAME        @ Loop until user types END on a line by itself
  124. "" 'LIN' STO
  125.       END CNVRT            @ Pack all lines into a single object
  126.     \>>
  127.   READLN
  128.     \<<
  129.       DO READCH DUP        @ Read characters until CR
  130. 'LIN' SWAP STO+
  131.       UNTIL 13 CHR
  132. SAME LIN 2 DISP
  133.       END
  134.     \>>
  135.   FIXLN     
  136.     \<< \-> l
  137.       \<< 1 CF             @ Check for occurences of \<< \>> \->
  138.         DO l
  139.           CASE l           @ Loop until no more occurences are found,
  140. "\\<<" POS                 @ converting each occurence on the way to the 48
  141.             THEN l         @ representation.
  142. "\\<<" POS "\<<  "         @
  143. REPL                       @ More special characters can be added as needed.
  144.             END l          @ Just add a new case.
  145. "\\>>" POS                 @ Remember to replace the number of characters you
  146.             THEN l         @ remove with an identical number of characters.
  147. "\\>>" POS "  \>>"        
  148. REPL
  149.             END l
  150. "\\->" POS
  151.             THEN l
  152. "\\->" POS "\->  "
  153. REPL
  154.             END 1
  155. SF
  156.           END 'l'
  157. STO
  158.         UNTIL 1 FS?       @ Flag 1 is a boolean used to tell us if we are done
  159.         END l
  160.       \>>
  161.     \>>
  162.   CNVRT
  163.     \<< DROP "" DEPTH     @ Drop the "END" string off the stack
  164. \-> d
  165.       \<<
  166.         IF d 1 >          @ Combine everything on the stack into one string
  167.         THEN 2 d
  168.           START +
  169.           NEXT
  170.         END OBJ\->        @ Convert the string into an object
  171.       \>>
  172.     \>>
  173.   READCH
  174.     \<<
  175.       DO                  @ Wait until the user types a key on the terminal
  176.       UNTIL BUFLEN
  177. DROP 0 >
  178.       END 1 SRECV         @ Get one character at a time!
  179. DROP \-> c
  180.       \<<
  181.         CASE c 13         @ If the character is a return then echo CR/LF
  182. CHR SAME
  183.           THEN c 10
  184. CHR + XMIT DROP c
  185.           END c 8         @ If the character is a backspace, then erase the
  186. CHR SAME                  @ character from the terminal, and remove it from
  187.           THEN c          @ the current line.
  188. " " + c + XMIT DROP
  189. DECLN ""
  190.           END c
  191. XMIT DROP c               @ Otherwise, just echo the character.
  192.         END
  193.       \>>
  194.     \>>
  195.   DECLN
  196.     \<< LIN 1 LIN 
  197. SIZE 1 - SUB 'LIN'
  198. STO
  199.     \>>
  200.   LIN ""
  201. END
  202.  
  203.